package is.bean.entity.department;

import is.bean.entity.NamedEntity;
import java.io.Serializable;

/**
 * Data container for department bean
 *
 * @author aspr0
 */
public class Department implements NamedEntity, Serializable, Cloneable
{
    private Integer id;
    private String name;
    private Integer parentId;
    private Integer regionId;
    private Integer bossId;

//    public Department() //nullary constructor to avoid InstantiationException ?
//    {
//    }
    public Integer getBossId()
    {
        return bossId;
    }

    public void setBossId(Integer bossId)
    {
        this.bossId = bossId;
    }

    @Override
    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    @Override
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Integer getParentId()
    {
        return parentId;
    }

    public void setParentId(Integer parentId)
    {
        this.parentId = parentId;
    }

    public Integer getRegionId()
    {
        return regionId;
    }

    public void setRegionId(Integer regionId)
    {
        this.regionId = regionId;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final Department other = (Department) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id)))
        {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name))
        {
            return false;
        }
        if (this.parentId != other.parentId && (this.parentId == null || !this.parentId.equals(other.parentId)))
        {
            return false;
        }
        if (this.regionId != other.regionId && (this.regionId == null || !this.regionId.equals(other.regionId)))
        {
            return false;
        }
        if (this.bossId != other.bossId && (this.bossId == null || !this.bossId.equals(other.bossId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 89 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 89 * hash + (this.parentId != null ? this.parentId.hashCode() : 0);
        hash = 89 * hash + (this.regionId != null ? this.regionId.hashCode() : 0);
        hash = 89 * hash + (this.bossId != null ? this.bossId.hashCode() : 0);
        return hash;
    }

    /**
     * For deferred boss write in XdumperImporter
     * @return
     */
    @Override
    public Object clone()
    {
        Department cloned = new Department();

        cloned.setId(id);
        cloned.setName(name);
        cloned.setParentId(parentId);
        cloned.setBossId(bossId);
        cloned.setRegionId(regionId);

        return cloned;
    }
}
